package com.microboot.client;

import com.microboot.interceptor.ClientLoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;


@Slf4j
public class CXFClientDynamicProvince {

    public static void main(String[] args) throws Exception {
        //WebService服务地址
        String address = "http://localhost:8080/services/MessageService?wsdl";
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient(address);
        client.getOutInterceptors().add(new ClientLoginInterceptor("longxian","root123"));//设置认证账户信息
        String message = "CXFClientDynamic =>> 测试调用数据是否成功";
        Object[] result = client.invoke("echo", message);
        log.info("CXFClientDynamic-调用服务接口返回数据信息为：{}",result[0]);
    }
}
